package org.pombo.sqm;

import org.pombo.gtm.Action;
import org.pombo.gtm.StrategyNode;

class OpponentNodeProbabilityCalculator implements NodeProbabilityCalculator<StrategyNode> {

	private StrategyNode node;
	private ProbabilityCalculatorFactory calculate;

	OpponentNodeProbabilityCalculator(ProbabilityCalculatorFactory probCalcFactory) {
		this.calculate = probCalcFactory;
	}

	public void setNode(StrategyNode node) {
		this.node = node;
	}

	public NodeProbabilities nodeProbabilities(double baseProbability) {
		NodeProbabilities nodeProbabilities = new NodeProbabilities();
		for (Action action : this.node.getActions()) {
			NodeProbabilities branchProbabilities = this.calculate.on(this.node.getNodeForAction(action)).nodeProbabilities(baseProbability);
			nodeProbabilities.add(branchProbabilities);
		}
		return nodeProbabilities;
	}

}
